package com.lecture.java8.file;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;

/**
 * @author luyn
 * @version 1.0
 * @description
 * @date 2020/12/22 10:11
 */
public class FileReadTest {

    public static void main(String[] args) {
        try {
            BufferedReader reader = new BufferedReader(new FileReader("C:\\Users\\luyn\\Desktop\\卢亚南日报\\2020_4_23.txt"));
            String tmp;
            while ((tmp = reader.readLine()) != null) {
                //System.out.println(tmp);
            }
            reader.close();
            System.out.println("--------------------分割线--------------------");
            InputStream inputStream = new FileInputStream(new File("C:\\Users\\luyn\\Desktop\\卢亚南日报\\2020_4_23.txt"));
            byte[] buff = new byte[1024];
            String tmp2;
            while (inputStream.read(buff,0, 1024) != -1) {
                System.out.println(new String(buff, StandardCharsets.UTF_8));
            }
            inputStream.close();
            System.out.println("--------------------分割线--------------------");
            //jdk8读取文件信息
            byte[] s = Files.readAllBytes(Paths.get("C:\\Users\\luyn\\Desktop\\卢亚南日报\\2020_4_23.txt"));
            String str = new String(s, StandardCharsets.UTF_8);
            //System.out.println(str);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {

        }
    }
}
